package com.yklx.youke.admin.service.impl;

import com.yklx.youke.entity.Course;
import com.yklx.youke.admin.mapper.CourseMapper;
import com.yklx.youke.admin.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    
    @Autowired
    private CourseMapper courseMapper;

    @Override
    public List<Course> getUserCourses(String userId) {
        // 实际实现中需要根据用户角色查询课程
        // 这里是简化实现，返回所有课程
        return courseMapper.getAllCourses();
    }

    @Override
    public List<Course> getAllCourses() {
        return courseMapper.getAllCourses();
    }

    @Override
    public Course getCourseById(String courseId) {
        return courseMapper.getCourseById(courseId);
    }

    @Override
    public boolean createCourse(Course course) {
        int result = courseMapper.insertCourse(course);
        return result > 0;
    }

    @Override
    public boolean updateCourse(Course course) {
        int result = courseMapper.updateCourse(course);
        return result > 0;
    }

    @Override
    public boolean deleteCourse(String courseId) {
        int result = courseMapper.deleteCourse(courseId);
        return result > 0;
    }
}